const terserPlugin = require('terser-webpack-plugin')

const env = process.env.NODE_ENV;
module.exports = {
  publicPath: '/',
  outputDir: 'dist/', // 输出文件目录
  css: {
    loaderOptions: {
      sass: {
        prependData: `@import "./src/assets/scss/color";`,
      },
    },
  },
  devServer: {
    disableHostCheck: true,
    open: true,
    port: 8080,
    host: '0.0.0.0',
    proxy: {
      '': {
        target: "http://wavecomputing.top/",
        // target: 'http://10.1.101.125:8717/',
        changeOrigin: true,
      }
    },
  },
  configureWebpack: (config) => {
    if (env === 'production') { // 只有生产环境执行此操作
      config.plugins.push(
      new terserPlugin({
          terserOptions: {
            ecma: undefined,
            warnings: false,
            parse: {},
            compress: {
              drop_debugger: true, // console
              drop_console: true,
              pure_funcs: ['console.log'] // 只要打包就移除console
            },
          },
          sourceMap: false,
          parallel: true,
        }),
      );
    }
  },
  productionSourceMap: !(env === 'production')
}
